﻿@{
    ViewBag.Title = "我的任务单";
    Layout = "~/Views/Shared/_LayoutKoJS.cshtml";
}

    <div class="aux-body">
        <!--<h1 class="itemtitle">My Resource</h1> -->
        <div class="aux-tabcontent">
            <div class="fx-grid">
                <div id="fx-scrollbar" style="width: 900px;">
                    <!-- style变化 height:650px; -->
                    <div id="fx-scrollbar-scrollable" style="width: 950px;">
                        <!-- style变化 -->
                        <div class="fx-grid-container fx-scrollbar-content" style="overflow: visible; width: 900px;">
                            <!-- style变化 -->
                            <div>
                                <table id="gridTableList">
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

@section scripts {
    <script type="text/javascript">
        $("#LayoutMyTask").addClass("selected");
        $(document).ready(function () {
            $("#gridTableList").jqGrid({
            @*url: '/API'+'@Url.Action("GetRule", "InspectionRuleAPI")',
            datatype: 'json',*@
                url: '',
                datatype: 'local',
                rowNum: 10000,
                colNames: [ '巡检单ID', '巡检单名称', '巡检单描述', '状态', '执行人', 'RequestID', 'Submitter', '生成巡检单时间', 'AssignedTo', 'LastModifiedBy', '最后更新时间', 'ShortDescription', 'StatusHistory', 'TcChr_Department'
                    , 'TcChr_Office', 'TcChr_MarkAsDelete', 'TcChr_TicketID', 'OcChr_MarkAsDelete'],
                colModel: [
                    { index: "636871917", name: "TaskID", sorttype: "text", align: "center", width: 100 },
                    { index: "636871911", name: "TcChr_Name", sorttype: "text" },
                    { index: "636871913", name: "TcChr_Description", sorttype: "text" },
                    { index: "636870918", name: "Status", sorttype: "text", formatter: FormateStatus, width: 60 },
                    { index: "636871912", name: "TcChr_FullName", sorttype: "text", width: 80 },
    { index: "1", name: "RequestID", key: true, sorttype: "text", hidden: true }, 
    { index: "636870913", name: "Submitter", sorttype: "text", hidden: true},
    { index: "636870914", name: "CreateDate", sorttype: "date", formatter: ISCreateDate, width: 120 },
    { index: "636870915", name: "AssignedTo", sorttype: "text", hidden: true },
    { index: "636870916", name: "LastModifiedBy", sorttype: "text", hidden: true },
    { index: "636870917", name: "ModifiedDate", sorttype: "date", formatter: DateModify ,width: 120 },
    { index: "636870919", name: "ShortDescription", sorttype: "text", hidden: true },
    { index: "636870910", name: "StatusHistory", sorttype: "text", hidden: true },
    { index: "636870911", name: "TcChr_Department", sorttype: "text", hidden: true },
    { index: "636870912", name: "TcChr_Office", sorttype: "text", hidden: true },   
    { index: "636871914", name: "TcChr_MarkAsDelete", sorttype: "text", hidden: true },
    { index: "636871915", name: "TcChr_TicketID", sorttype: "text", hidden: true },
    { index: "636871916", name: "OcChr_MarkAsDelete", sorttype: "text", hidden: true },
                ],
                jsonReader: {
                    repeatitems: false,
                    id: "RequestID"
                },
                mtype: "GET",
                autowidth: true,
                sortname: 'ModifiedDate',
                sortorder: 'desc',
                postData: {
                    Permission: 'public',
                }, //发送数据
                prmNames: {
                    id: 'Type'
                },
                scrollOffset: 0,
                height: "430",
                width: "980",
                viewrecords: true,
                gridview: true,

                onSelectRow: function () {
                },
                ondblClickRow: function () {
                    var IsTaskFrame = "TaskFrame"
                    var id = jQuery("#gridTableList").jqGrid('getGridParam', 'selrow');
                    if (id) {
                        var ret = jQuery("#gridTableList").jqGrid('getRowData', id);
                        //alert("id=" + ret.RequestID + " invdate=" + ret.ShortDescription + "...");
                        window.location.href = "/InspectionTask/Index?GTicketID=" + ret.TaskID + "&PageName=" + IsTaskFrame;
                        //window.open("../InspectionTicket/Index?GTicketID=" + ret.TaskID);
                    } else {
                        alert("Please select row");
                    }
                },
                gridComplete: function () {
                },
                loadComplete: function () {
                }
            });
            LoadHosts();
        });
        function LoadHosts() {
            var IsSubmitterInfo = '@ViewBag.FullName';
            //alert(IsTaskID);
            var data = {};
            jQuery("#gridTableList").jqGrid("setGridParam", {
                //url: "/API/InspectionTicketAPI/GetAll", //设置表格的url
                url: "/API/InspectionTaskAPI/GetMyTaskAll?SubmitterInfo=" + IsSubmitterInfo, //设置表格的url
                datatype: "json", //设置数据类型
                postData: { strJson: data }
            }).trigger("reloadGrid");
        }

        function FormateStatus(cellvalue, options, rowObject) {
            var Status = rowObject.Status;
            switch (Status) {
                //case 0: return '新建';
                case 1: return '进行中';
                case 2: return ' 已取消';
                case 3: return '已完成';
            }
        }

        function DateModify(cellvalue, options, rowObject) {
            return rowObject.ModifiedDate.replace("T", " ").replace("+08:00", "");
        }

        function ISCreateDate(cellvalue, options, rowObject) {
            return rowObject.CreateDate.replace("T", " ").replace("+08:00", "");
        } 
    </script>
}